import Vue from 'vue'
import router from "@/router";
// 按钮权限封装
Vue.directive('permission', {
  inserted: function (el, binding) {
    console.log("debug log router--> ",router.currentRoute.meta)
    
    const action = binding.value.action
    const currentRight = router.currentRoute.meta.jurisdiction
    if (currentRight) {
      if (currentRight.indexOf(action) == -1) {
        // 不具备权限
        const type = binding.value.effect
        if (type === 'disabled') {
          el.disabled = true
          el.classList.add('is-disabled')
        } else {
          el.parentNode.removeChild(el)
        }
      }
    }
  }
})